package com.hspedu.newData.dmsxl.动态规划.基础;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-06 
 * @Version: 1.0
 */

public class LC300最长递增子序列 {

    // 普通动规
    public int lengthOfLIS(int[] nums) {

        if (nums.length == 0) return 0;

        int len = nums.length;
        int[] dp = new int[len];
        dp[0] = 1;
        int res = 1;
        for (int i = 1; i < len; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i],dp[j] + 1);
                }
            }
            res = Math.max(res,dp[i]);
        }
        return res;
    }

    // 贪心

    @Test
    public void test() {
        // 测试代码

        lengthOfLIS(new int[]{4,10,4,3,8,9});
    }
}
